package com.cms.util;


public class UserDataAction{ /*extends AbstractAction {

	*//**
	 * 
	 *//*
	private static final long serialVersionUID = 1L;

	public UserDataAction() {
		pageTag = -1;
		service = new UserDataServiceImpl();
	}
	
	private UserDataService service;

	private String date1;
	private String date2;
	private String channel;
	private String province;
	private String region;
	private String dimension;
	private List<Channel> channels;
	private List<UserData> datas;
	
	private int pageTag;
	
	private boolean isCoop;
	
	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	public boolean getIsCoop() {
		return isCoop;
	}

	public void setIsCoop(boolean isCoop) {
		this.isCoop = isCoop;
	}

	public String data()
	{
		ChannelService cs = new ChannelServiceImpl();
		if (pageTag < 0)
		{
			date1 = formatDate(new Date(), "yyyy-MM") + "-01";
			date2 = formatDate(new Date(), "yyyy-MM-dd");

			channels = new ArrayList<Channel>();
			List<Channel> chs = cs.getChannels();
			AccountService as = new AccountServiceImpl();
			List<String> chcodes = as.getAccountChannels(operator.getId());
			for (Channel ch : chs) {
				if (chcodes.contains(ch.getCode()))
					channels.add(ch);
			}
		}
		else
		{
			datas = new ArrayList<UserData>();

			try {
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				Date d1 = sdf.parse(date1);
				Date d2 = sdf.parse(date2);
				if (d1.after(d2))
				{
					Date d = d1;
					d1 = d2;
					d2 = d;
				}
				if (isCoop) {
					Date d = formatQueryDate(new Date());
					if (d1.getTime() > d.getTime())
						return SUCCESS;
					
					d1 = formatQueryDate(d1);
					d2 = formatQueryDate(d2);
				}
				date1 = sdf.format(d1);
				date2 = sdf.format(d2);
			} 
			catch (Exception e) {}
			
			List<com.query.model.UserData> list = service.getUserData(operator, isCoop, date1, date2,
					channel, province, region, dimension);
			if (list != null) {
				channels = cs.getChannels();
				for (com.query.model.UserData d : list) {
					UserData ud = new UserData(d);
					for (Channel ch : channels) {
						if (ch.getCode().equals(d.getChannel())) {
							ud.setChannelName(ch.getName());
							break;
						}
					}
					datas.add(ud);
				}
			}
		}
		return SUCCESS;
	}
	
	public static Date formatQueryDate(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.HOUR_OF_DAY, -36);
		if (date.getTime() > cal.getTime().getTime())
			return cal.getTime();
		return date;
	}
	
	public String changeprovince()
	{
		return SUCCESS;
	}
	
	public String detail()
	{
		return SUCCESS;
	}

	*//**
	 * @return the date1
	 *//*
	public String getDate1() {
		return date1;
	}

	*//**
	 * @param date1 the date1 to set
	 *//*
	public void setDate1(String date1) {
		this.date1 = date1;
	}

	*//**
	 * @return the date2
	 *//*
	public String getDate2() {
		return date2;
	}

	*//**
	 * @param date2 the date2 to set
	 *//*
	public void setDate2(String date2) {
		this.date2 = date2;
	}

	*//**
	 * @return the channels
	 *//*
	public List<Channel> getChannels() {
		return channels;
	}

	*//**
	 * @param channels the channels to set
	 *//*
	public void setChannels(List<Channel> channels) {
		this.channels = channels;
	}

	*//**
	 * @return the province
	 *//*
	public String getProvince() {
		return province;
	}

	*//**
	 * @param province the province to set
	 *//*
	public void setProvince(String province) {
		this.province = province;
	}

	*//**
	 * @return the region
	 *//*
	public String getRegion() {
		return region;
	}

	*//**
	 * @param region the region to set
	 *//*
	public void setRegion(String region) {
		this.region = region;
	}

	*//**
	 * @return the datas
	 *//*
	public List<UserData> getDatas() {
		return datas;
	}

	*//**
	 * @param datas the datas to set
	 *//*
	public void setDatas(List<UserData> datas) {
		this.datas = datas;
	}

	*//**
	 * @return the dimension
	 *//*
	public String getDimension() {
		return dimension;
	}

	*//**
	 * @param dimension the dimension to set
	 *//*
	public void setDimension(String dimension) {
		this.dimension = dimension;
	}

	*//**
	 * @return the pagTag
	 *//*
	public int getPageTag() {
		return pageTag;
	}

	*//**
	 * @param pagTag the pagTag to set
	 *//*
	public void setPageTag(int pageTag) {
		this.pageTag = pageTag;
	}

*/}
